<?php
/**
 * Created by Pako
 * Date: 2019/5/15
 * Time: 21:18
 */

namespace App\Http\Controllers\Admin\Ad;


use App\Http\Request\Ad\AdStore;
use App\Repositories\Ad\AdRespository;
use Illuminate\Http\Request;

class AdController
{
    private $ad ;

    public function __construct(AdRespository $ad)
    {
        $this->ad = $ad;
    }


    public function index(Request $request)
    {
        $params = $request->all();
        return $this->ad->index($params);
    }

    /**
     * 描术
     *
     * @author Pako
     * @createTime 2019/5/15 21:55
     * @param AdStore $ad
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(AdStore $ad,Request $request)
    {
        $params = $ad->validated($request);
        return $this->ad->store($params);
    }

    /**
     * 描术
     *
     * @author Pako
     * @createTime 2019/5/15 21:55
     * @param AdStore $ad
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function save(AdStore $ad,Request $request)
    {
        $params = $ad->validated($request);
        return $this->ad->save($params);
    }

    public function del(Request $request)
    {
        $ad_id = $request->input('ad_id',0);
        return $this->ad->del($ad_id);
    }
}